package components

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

// InitGormController 初始化数据库
func InitGormController() (*gorm.DB, error) {

	dsn := "root:Qwertyuiop0928..@tcp(dongsongkeji.com.cn:12928)/i18n_template?charset=utf8mb4&parseTime=True&loc=Local"
	// dsn := "root:Qwertyuiop0928..@tcp(localhost:3306)/i18n_template?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		return nil, err
	}
	DB = db
	return db, nil

}
